using AntdUI;
using CKS.Core.Framework;
using FreeSql;
using FreeSql.DataAnnotations;
using System.Reflection;

namespace CKS.AGV.Server.ViewModel
{
	/// <summary>
	/// agv路径点
	/// </summary>
	[Table(Name ="agv_path_point")]
	public class View_path_point : AntdUI.NotifyProperty
    {
        private int agvModbusAddr;
        private int upperModbusAddr;
        private int point;
        private int stationId;
        private int stationArea;
        private string remark;

        /// <summary>
        /// 路径点编号
        /// </summary>
        [Column(IsIdentity = true, IsPrimary = true)]
        public long Id { get; set; }
        /// <summary>
        /// 路径点值
        /// </summary>
        public int Point { get => point;
            set { point = value; OnPropertyChanged("Point"); }
        }
        /// <summary>
        /// 工站ID
        /// </summary>
        public int StationId { get => stationId;
            set { stationId = value; OnPropertyChanged("StationId"); }
        }
        /// <summary>
        /// 区域
        /// </summary>
        public int StationArea { get => stationArea;
            set { stationArea = value; OnPropertyChanged("StationArea"); }
        }
        /// <summary>
        /// 坐标类型:1满料坐标 2空料坐标  3回收坐标
        /// </summary>
        public int PointType { get; set; }

        [Column(IsIgnore =true)]
        public CellText PointTypeCellText
        {
            get
            {
                var text = PointType switch
                {
                    1 => "满料坐标",
                    2 => "空料坐标",
                    3 => "回收坐标",
                    0 => "--",
                    _ => ""
                };
                return new CellText(text)
                {
                    //支持所有单元格控件
                    //支持所有单元格控件
                    DropDownItems = new ISelectItem[]
                         {
                             new AntdUI.SelectItem("满料坐标",1),
                              new AntdUI.SelectItem("空料坐标",2),
                              new AntdUI.SelectItem("回收坐标",3),
                               new AntdUI.SelectItem("--",0),
                         },
                    DropDownValueChanged = (value) =>
                    {
                        int badge = (value as AntdUI.SelectItem).Tag.ToInt();
                        PointType = badge;
                        OnPropertyChanged("PointTypeCellText");
                    }
                };

            }

            //set => writeFromButton = value;
        }

        public int AgvModbusAddr { get => agvModbusAddr; 
            set { agvModbusAddr = value; OnPropertyChanged("AgvModbusAddr"); } }
        public int UpperModbusAddr { get => upperModbusAddr; 
            set { upperModbusAddr = value; OnPropertyChanged("UpperModbusAddr"); } }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get => remark; 
            set { remark = value; OnPropertyChanged("Remark"); } }
        /// <summary>
        /// 最后更新时间
        /// </summary>
        public DateTime UpdateTime { get; set; }
		/// <summary>
		/// 创建时间
		/// </summary>
		public DateTime CreatedTime { get; set; }
		/// <summary>
		/// 
		/// </summary>
		public bool IsDeleted { get; set; }
	}
}